﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for ContachOrder
/// </summary>
public class ContachOrder
{
    
    SqlCommand cmd;
    SqlDataReader dr;
	public ContachOrder()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public List<ObjContactOrder> getContactOrder(int id)
    {
        string constr = System.Configuration.ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
        SqlConnection sqlConnection = new SqlConnection(constr);

        sqlConnection.Open();
        cmd = new SqlCommand("sp_ContactOrderByOrderID", sqlConnection);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter[] sqla = new SqlParameter[1];
        sqla[0] = new SqlParameter("order_id", DbType.Int32);
        sqla[0].Value = id;
        cmd.Parameters.AddRange(sqla);
        dr = cmd.ExecuteReader();
        ObjContactOrder objContactOrder;
        List<ObjContactOrder> lst = new List<ObjContactOrder>();
        while (dr.Read()){
            objContactOrder=new ObjContactOrder();
            objContactOrder.Contact_order_id=int.Parse(dr["contact_order_id"].ToString());
            objContactOrder.Tour_id=int.Parse(dr["Tour_id"].ToString());
            objContactOrder.So_luong=int.Parse(dr["so_luong"].ToString());
            objContactOrder.Gia=int.Parse(dr["gia"].ToString());
            objContactOrder.Order_id=int.Parse(dr["order_id"].ToString());
            objContactOrder.Ten_tour = dr["ten_tour"].ToString();
            lst.Add(objContactOrder);
        }
        dr.Close();
        sqlConnection.Close();
        return lst;
    }
}